﻿using Calligraphy.Models;
using CalligraphyWeb.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CalligraphyWeb.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Tab = Request.QueryString["tab"] == null ? "" : Request.QueryString["tab"];
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            return View();
        }

        public string InitializeJSON()
        {
            string backgroundUrl = "/Data/Backgrounds/";
            string thumbnailUrl = "/Data/ItemImages/";
            string templateBackgroundUrl = "/Data/TemplateBackgrounds/";
            string TemplateImageUrl = "/Data/TemplateImages/";
            string galleriesUrl = "/Data/Galleries/";

            HomeModel model = new HomeModel();

            model.Templates = Template.Get(isLazy: false);

            return JsonConvert.SerializeObject(model, Formatting.Indented,
                new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });

        }
    }
}
